<?php
/**
 * Created by PhpStorm.
 * User: zhaojia
 * Date: 15-9-18
 * Time: 下午1:49
 */
class Question extends CI_Model{
    public function __construct(){
        parent::__construct();
        $this->load->database();
        $this->load->model('Question');

    }

    public function add_data($data){
        $this->db->insert('question',$data);
    }

    public function get_data($id=null){

        if($id==null){
            $query=$this->db->get('question')->result_array();
            return $query;
        }else{
            $data=$this->db->where(array('id'=>$id))->get('question')->result_array();
            return $data[0];
        }
    }

    public function save_data($data,$id){
        $this->db->where(array('id'=>$id))->update('question',$data);

    }

    public function get_ques($id){
        $data=$this->db->where(array('cid'=>$id))->get('question')->result_array();
        return $data;
    }

    public function get_quest($id){
        $data=$this->db->where(array('id'=>$id))->get('question')->row_array();
        return $data;
    }

    public function get_index(){
        $query=$this->db->get('question',6)->result_array();
        return $query;
    }

    public function del_data($id){
        $this->db->where(array('id'=>$id))->delete('question');

    }

}